package ky.cse.proj.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import ky.cse.proj.service.snsDaoService;
import ky.cse.proj.vo.snsVO;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class snsController {
	
	@Resource(name="snsDaoService")
	private snsDaoService snsservice;
	
	@SuppressWarnings("unchecked")
	@RequestMapping(value="/mySnsList.do")
	public String firstControll(HttpServletRequest req, HttpServletRequest resp, ModelMap map){
		List<snsVO> list=snsservice.selectSnsTb();
		map.addAttribute("list",list);
		return "mySnsList";
	}
	
	@RequestMapping(value="/regSnsPage.do")
	public String regSnsPageControll(HttpServletRequest req, HttpServletRequest resp){
		return "regSnsPage";
	}
	
	@RequestMapping(value="/regSns.do")
	@ResponseBody
	public void resSnsControll(HttpServletRequest req, HttpServletRequest resp){
		snsVO snsVo=new snsVO();
		snsVo.setSns_writer("admin");
		snsVo.setSns_content(req.getParameter("content"));
		
		snsservice.insertSns(snsVo);
	}
}
